package com.pangu.web.captcha;

import java.awt.Color;
import java.awt.Font;

import com.octo.captcha.component.image.backgroundgenerator.BackgroundGenerator;
import com.octo.captcha.component.image.backgroundgenerator.GradientBackgroundGenerator;
import com.octo.captcha.component.image.color.RandomRangeColorGenerator;
import com.octo.captcha.component.image.fontgenerator.FontGenerator;
import com.octo.captcha.component.image.fontgenerator.RandomFontGenerator;
import com.octo.captcha.component.image.textpaster.RandomTextPaster;
import com.octo.captcha.component.image.textpaster.TextPaster;
import com.octo.captcha.component.image.wordtoimage.ComposedWordToImage;
import com.octo.captcha.component.image.wordtoimage.WordToImage;
import com.octo.captcha.component.word.wordgenerator.RandomWordGenerator;
import com.octo.captcha.component.word.wordgenerator.WordGenerator;
import com.octo.captcha.engine.image.ListImageCaptchaEngine;
import com.octo.captcha.image.gimpy.GimpyFactory;

public class CaptchaEngineEx extends ListImageCaptchaEngine {

	@Override
	protected void buildInitialFactories() {
		WordGenerator wgen = new RandomWordGenerator("abcdefghijklmnopqrstuvwxyz123456789");
		RandomRangeColorGenerator cgen = new RandomRangeColorGenerator(new int[] { 0, 100 },
				new int[] { 0, 100 }, new int[] { 0, 100 });
		TextPaster tp = new RandomTextPaster(new Integer(6), new Integer(6), cgen, true);
		// BackgroundGenerator bg = new FunkyBackgroundGenerator(new
		// Integer(150), new Integer(50));
		BackgroundGenerator bg = new GradientBackgroundGenerator(new Integer(150), new Integer(50),
				Color.white, Color.white);
		Font[] fontsList = new Font[] { new Font("Arial", 0, 10), new Font("Tahoma", 0, 10),
				new Font("Verdana", 0, 10) };
		FontGenerator fg = new RandomFontGenerator(new Integer(15), new Integer(30), fontsList);

		WordToImage wordToImage = new ComposedWordToImage(fg, bg, tp);
		addFactory(new GimpyFactory(wgen, wordToImage));
	}
}
